import * as actionTypes from '../constants/store.js'
import item from "../components/List/item";

const initialState=[];

export default function store(state=initialState,action) {
   switch (action.type){
       case actionTypes.STORE_UPDATE:
           return action.data;
       case actionTypes.STORE_ADD:
            state.unshift(action.data);//推到数组最前面
            return state;
       case actionTypes.STORE_RM:
            return state.filter( item => {
                if (item.id !== action.data.id){//返回所有不等于 action.data.id的数据
                    return item;
                }
            });
       default:
           return state
   }
}